package com.css.fxfzfxqh.modules.vulnerabilityData.verify;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import com.css.fxfzfxqh.modules.vulnerabilityData.entity.DxPipeNetworkEntity;
import com.css.fxfzfxqh.util.PlatformObjectUtils;
import org.springframework.stereotype.Component;

@Component
public class DxPipeNetworkExcelVerifyHandler implements IExcelVerifyHandler<DxPipeNetworkEntity> {
    @Override
    public ExcelVerifyHandlerResult verifyHandler(DxPipeNetworkEntity dxPipeNetworkEntity) {
        ExcelVerifyHandlerResult result = new ExcelVerifyHandlerResult(true);
        StringBuilder message = new StringBuilder("");

        if (PlatformObjectUtils.isEmpty(dxPipeNetworkEntity.getCdpnName())) {
            result.setSuccess(false);
            message.append("管道名称 不能为空！");
        }
        if (PlatformObjectUtils.isEmpty(dxPipeNetworkEntity.getCdpnClass())) {
            result.setSuccess(false);
            message.append("管道类型 不能为空！");
        }
        if (PlatformObjectUtils.isEmpty(dxPipeNetworkEntity.getStartId())) {
            result.setSuccess(false);
            message.append("起始编号 不能为空！");
        }
        if (PlatformObjectUtils.isEmpty(dxPipeNetworkEntity.getEndId())) {
            result.setSuccess(false);
            message.append("终点编号 不能为空！");
        }
        if (PlatformObjectUtils.isEmpty(dxPipeNetworkEntity.getLongitude())) {
            result.setSuccess(false);
            message.append("经度 不能为空！");
        }
        if (PlatformObjectUtils.isEmpty(dxPipeNetworkEntity.getLatitude())) {
            result.setSuccess(false);
            message.append("纬度 不能为空！");
        }
        if (PlatformObjectUtils.isEmpty(dxPipeNetworkEntity.getLength())) {
            result.setSuccess(false);
            message.append("管道长度 不能为空！");
        }
        if (PlatformObjectUtils.isEmpty(dxPipeNetworkEntity.getMaterial())) {
            result.setSuccess(false);
            message.append("管材 不能为空！");
        }
        result.setMsg(message.toString());
        return result;
    }
}
